package com.dwk.rabbitMQ3;


import com.dwk.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * 消息在手动应答的时候是不丢失的，会回队列重新消费
 */
public class Task02 {
    private static final String TASK_QUEUE_NAME="ack_queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();

        channel.queueDeclare(TASK_QUEUE_NAME,false,false,false,null);
        //从控制台接收信息代码
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            String message=scanner.next();
            channel.basicPublish("",TASK_QUEUE_NAME,null,message.getBytes("utf-8"));
            System.out.println("消息发送完毕");
        }

    }
}
